package main

import "fmt"

/**
数组是值类型
◆[10]int 和[20]int是不同类型
◆调用func f(arr [10]irt)会拷贝数组
 */
func printArray(arr [2]int)  {
	arr[0] = 25
	for i, v := range arr {
		fmt.Println("索引:", i, "值:", v)
	}
}

func printArrayPointer(arr *[2]int)  {
	arr[0] = 25
	for i, v := range arr {
		fmt.Println("索引:", i, "值:", v)
	}
}


var b = [...]int{1, 2, 3, 4}
var c = [5]int{0:1, 3:5}
var d = [2][3]int{{1:12},{0:21}}


func main() {
	a := [2]int{1, 2}
	//b := [...]int{1, 2, 3, 4}
	//c := [5]int{0:1, 3:5}
	//d := [2][3]int{{1:12},{0:21}}
	//fmt.Println(a, b, c, d)
	fmt.Println(a)
	printArray(a)
	fmt.Println(a)
	// 指针，实现引用传递
	printArrayPointer(&a)
	fmt.Println(a)
}
